package com.shyroke.daydayzhuandao.respository;

import com.shyroke.daydayzhuanapi.entity.AppEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface AppRepository extends BaseRepository<AppEntity,Integer>{
    List<AppEntity> findByOfflineOrderByIdDesc(Integer offline);

    List<AppEntity> findByIdInOrderByDownCountDesc(List<Integer> appIdList);

    List<AppEntity> findByOffline(int offline);

    @Modifying
    @Transactional(rollbackFor = Exception.class)
    @Query("update AppEntity p set p.downCount = p.downCount+1 where p.id = ?1")
    void updateCount(Integer appId);
}
